﻿// ———————————————————————–
// <copyright file="EventLinkRelationCode.cs" company="The MITRE Corporation">
//    Copyright (c) 2014 The MITRE Corporation. All rights reserved.
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
// </copyright>
// ———————————————————————–
/////////////////////////////////////////////////////////////////////////////////////////////////
// EventLinkRelationCode.cs:
//
// 
//
// Project: IC.NET - CAD Library
// Author:  Jim Cronin - MITRE
/////////////////////////////////////////////////////////////////////////////////////////////////

// Copyright (c) 2014 The MITRE Corporation. All rights reserved.
//
// NOTICE
// This software was produced for the U. S. Government
// under Contract No. FA8721-09-C-0001, and is
// subject to the Rights in Noncommercial Computer Software
// and Noncommercial Computer Software Documentation Clause
// (DFARS) 252.227-7014 (JUN 1995)

using System;

namespace EDXLSharp.NIEMCADLib
{
  public enum EventLinkRelationCode
  {
    /// <summary>
    /// The linked object is the parent of this object.
    /// </summary>
    Parent,

    /// <summary>
    /// The linked object is the producer of this object.
    /// </summary>
    ParentProducer,

    /// <summary>
    /// The linked object is the owner of this object.
    /// </summary>
    ParentOwner,

    /// <summary>
    /// The linked object is the manager of this object.
    /// </summary>
    ParentManager,

    /// <summary>
    /// The linked object is the leader (commander) of this object.
    /// </summary>
    ParentLeader,

    /// <summary>
    /// The linked object is the source of this object.
    /// </summary>
    ParentSource,

    /// <summary>
    /// The linked object is the tasking that elicited this object.
    /// </summary>
    ParentTasking,

    /// <summary>
    /// The linked object is a child of this object.
    /// </summary>
    Child,

    /// <summary>
    /// The linked object is a correlated element of this object.
    /// </summary>
    ChildCorrelated,

    /// <summary>
    /// The linked object is a fused element of this object.
    /// </summary>
    ChildFused,

    /// <summary>
    /// The linked object is an alternate element of this object.
    /// </summary>
    ChildAlternate,

    /// <summary>
    /// The linked object is a composite element of this object.
    /// </summary>
    ChildComposite,

    /// <summary>
    /// The linked object is a refinement of this object.
    /// </summary>
    Refinement,

    /// <summary>
    /// The linked object is an amplification of this object.
    /// </summary>
    RefinementAmplification,

    /// <summary>
    /// The linked object is a URL for a resource that is a refinement of this object.
    /// </summary>
    RefinementUrl,

    /// <summary>
    /// The linked object is a tasking from this object.
    /// </summary>
    Tasking,

    /// <summary>
    /// The linked object is an object of a tasking from this object.
    /// </summary>
    TaskingObject,

    /// <summary>
    /// The linked object is an indirect object of a tasking from this object.
    /// </summary>
    TaskingIndirect,

    /// <summary>
    /// The linked object is a subject of a tasking from this object.
    /// </summary>
    TaskingSubject,

    /// <summary>
    /// The linked object is at this object.
    /// </summary>
    TaskingPrepositionAt,

    /// <summary>
    /// The linked object is by this object.
    /// </summary>
    TaskingPrepositionBy,

    /// <summary>
    /// The linked object is with this object.
    /// </summary>
    TaskingPrepositionWith,

    /// <summary>
    /// The linked object is from this object.
    /// </summary>
    TaskingPrepositionFrom,

    /// <summary>
    /// The linked object is regarding this object.
    /// </summary>
    TaskingPrepositionRegarding,

    /// <summary>
    /// The linked object is via this object.
    /// </summary>
    TaskingPrepositionVia
  }

  /// <summary>
  /// Helper methods for converting between the <see cref="EDXLSharp.NIEMCADLib.EventLinkRelationCode"/>
  /// enumeration and the corresponding XML enumeration values.
  /// </summary>
  public static class EventLinkRelationCodeHelpers
  {
    /// <summary>
    /// Gets the textual representation of the <see cref="EDXLSharp.NIEMCADLib.EventLinkRelationCode"/>
    /// </summary>
    /// <param name="code"><see cref="EDXLSharp.NIEMCADLib.EventLinkRelationCode"/></param>
    /// <returns>Text representation (XML enumeration value)</returns>
    public static string GetText(this EventLinkRelationCode code)
    {
      switch (code)
      {
        case EventLinkRelationCode.Parent:
          return "PARENT";
        case EventLinkRelationCode.ParentProducer:
          return "PARENT.PRODUCER";
        case EventLinkRelationCode.ParentOwner:
          return "PARENT.OWNER";
        case EventLinkRelationCode.ParentManager:
          return "PARENT.MANAGER";
        case EventLinkRelationCode.ParentLeader:
          return "PARENT.LEADER";
        case EventLinkRelationCode.ParentSource:
          return "PARENT.SOURCE";
        case EventLinkRelationCode.ParentTasking:
          return "PARENT.TASKING";
        case EventLinkRelationCode.Child:
          return "CHILD";
        case EventLinkRelationCode.ChildCorrelated:
          return "CHILD.CORRELATED";
        case EventLinkRelationCode.ChildFused:
          return "CHILD.FUSED";
        case EventLinkRelationCode.ChildAlternate:
          return "CHILD.ALTERNATE";
        case EventLinkRelationCode.ChildComposite:
          return "CHILD.COMPOSITE";
        case EventLinkRelationCode.Refinement:
          return "REFINEMENT";
        case EventLinkRelationCode.RefinementAmplification:
          return "REFINEMENT.AMPLIFICATION";
        case EventLinkRelationCode.RefinementUrl:
          return "REFINEMENT.URL";
        case EventLinkRelationCode.Tasking:
          return "TASKING";
        case EventLinkRelationCode.TaskingObject:
          return "TASKING.OBJECT";
        case EventLinkRelationCode.TaskingIndirect:
          return "TASKING.INDIRECT";
        case EventLinkRelationCode.TaskingSubject:
          return "TASKING.SUBJECT";
        case EventLinkRelationCode.TaskingPrepositionAt:
          return "TASKING.PREPOSITION.AT";
        case EventLinkRelationCode.TaskingPrepositionBy:
          return "TASKING.PREPOSITION.BY";
        case EventLinkRelationCode.TaskingPrepositionWith:
          return "TASKING.PREPOSITION.WITH";
        case EventLinkRelationCode.TaskingPrepositionFrom:
          return "TASKING.PREPOSITION.FROM";
        case EventLinkRelationCode.TaskingPrepositionRegarding:
          return "TASKING.PREPOSITION.REGARDING";
        case EventLinkRelationCode.TaskingPrepositionVia:
          return "TASKING.PREPOSITION.VIA";
        default:
          throw new ArgumentException("Unknown EventLinkRelationCode " + code);
      }
    }

    /// <summary>
    /// Gets the <see cref="EDXLSharp.NIEMCADLib.EventLinkRelationCode"/> representing the given value
    /// </summary>
    /// <param name="text">Text value (XML enumeration value)</param>
    /// <returns><see cref="EDXLSharp.NIEMCADLib.EventLinkRelationCode"/> representing the given value</returns>
    public static EventLinkRelationCode GetCode(string text)
    {
      switch (text)
      {
        case "PARENT":
          return EventLinkRelationCode.Parent;
        case "PARENT.PRODUCER":
          return EventLinkRelationCode.ParentProducer;
        case "PARENT.OWNER":
          return EventLinkRelationCode.ParentOwner;
        case "PARENT.MANAGER":
          return EventLinkRelationCode.ParentManager;
        case "PARENT.LEADER":
          return EventLinkRelationCode.ParentLeader;
        case "PARENT.SOURCE":
          return EventLinkRelationCode.ParentSource;
        case "PARENT.TASKING":
          return EventLinkRelationCode.ParentTasking;
        case "CHILD":
          return EventLinkRelationCode.Child;
        case "CHILD.CORRELATED":
          return EventLinkRelationCode.ChildCorrelated;
        case "CHILD.FUSED":
          return EventLinkRelationCode.ChildFused;
        case "CHILD.ALTERNATE":
          return EventLinkRelationCode.ChildAlternate;
        case "CHILD.COMPOSITE":
          return EventLinkRelationCode.ChildComposite;
        case "REFINEMENT":
          return EventLinkRelationCode.Refinement;
        case "REFINEMENT.AMPLIFICATION":
          return EventLinkRelationCode.RefinementAmplification;
        case "REFINEMENT.URL":
          return EventLinkRelationCode.RefinementUrl;
        case "TASKING":
          return EventLinkRelationCode.Tasking;
        case "TASKING.OBJECT":
          return EventLinkRelationCode.TaskingObject;
        case "TASKING.INDIRECT":
          return EventLinkRelationCode.TaskingIndirect;
        case "TASKING.SUBJECT":
          return EventLinkRelationCode.TaskingSubject;
        case "TASKING.PREPOSITION.AT":
          return EventLinkRelationCode.TaskingPrepositionAt;
        case "TASKING.PREPOSITION.BY":
          return EventLinkRelationCode.TaskingPrepositionBy;
        case "TASKING.PREPOSITION.WITH":
          return EventLinkRelationCode.TaskingPrepositionWith;
        case "TASKING.PREPOSITION.FROM":
          return EventLinkRelationCode.TaskingPrepositionFrom;
        case "TASKING.PREPOSITION.REGARDING":
          return EventLinkRelationCode.TaskingPrepositionRegarding;
        case "TASKING.PREPOSITION.VIA":
          return EventLinkRelationCode.TaskingPrepositionVia;
        default:
          throw new ArgumentException("Unknown EventLinkRelationCode " + text);
      }
    }
  }
}